import common from "./common";

export default {

    findTableCell(subject: Cypress.Chainable<any>, content: string): Cypress.Chainable<any> {
        return common.selectNode(subject, "td:contains('" + content + "')");
    },

    addCommands() {
        Cypress.Commands.add("findTableCell",
            {
                prevSubject: 'optional'
            },
            this.findTableCell);

        Cypress.Commands.add("findTableRow",
            {
                prevSubject: 'optional'
            },
            (subject: Cypress.Chainable<any>, content: string): Cypress.Chainable<any> => {
                return this.findTableCell(subject, content).parent("tr");
            });

        Cypress.Commands.add("noTableCell",
            (content: string): Cypress.Chainable<any> => {
                return cy.get("table").not("td:contains('" + content + "')");
            });
    }

}
